package com.ibeeking.found.content.b.rest.controller.v1;

import com.ibeeking.found.content.b.rest.service.IBroadcastAnchorService;
import com.ibeeking.found.content.service.common.param.BroadcastAnchorParam;
import com.ibeeking.found.content.service.common.query.BroadcastAnchorPageQuery;
import com.ibeeking.found.content.service.common.query.BroadcastAnchorQuery;
import com.ibeeking.found.content.service.common.vo.BroadcastAnchorVO;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName BroadcastController控制器
 * @Description
 * @Author ibeeking
 * @Date 2022-02-18 14:11
 **/
@RestController
@RequestMapping("/b/broadcast/v1/anchor")
public class BroadcastAnchorController {

    @Resource
    private IBroadcastAnchorService broadcastAnchorServiceImpl;

    /**
     * --------主播管理
     */
    @Log(logType = OperateLogTypeEnum.QUERY, describe = "主播列表")
    @PostMapping(value = "/list")
    public List<BroadcastAnchorVO> anchorList(@RequestBody BroadcastAnchorQuery broadcastAnchorQuery) {
        return broadcastAnchorServiceImpl.list(broadcastAnchorQuery);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "主播分页列表")
    @PostMapping(value = "/pageList")
    public Page<BroadcastAnchorVO> anchorPageList(@RequestBody BroadcastAnchorPageQuery broadcastAnchorPageQuery) {
        return broadcastAnchorServiceImpl.pageList(broadcastAnchorPageQuery);
    }

    @Log(logType = OperateLogTypeEnum.SAVE, describe = "主播添加")
    @PostMapping(value = "/add")
    public Boolean anchorAdd(@RequestBody @Validated BroadcastAnchorParam broadcastAnchorParam) {
        return broadcastAnchorServiceImpl.add(broadcastAnchorParam);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "主播修改")
    @PostMapping(value = "/modify")
    public Boolean anchorModify(@RequestBody @Validated BroadcastAnchorParam broadcastAnchorParam) {
        return broadcastAnchorServiceImpl.modify(broadcastAnchorParam);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "主播查看")
    @GetMapping(value = "/view/{id}")
    public BroadcastAnchorVO anchorView(@PathVariable("id") Long id) {
        return broadcastAnchorServiceImpl.view(id);
    }

    @Log(logType = OperateLogTypeEnum.DEL, describe = "主播删除")
    @PostMapping(value = "/del/{id}")
    public Boolean anchorDel(@PathVariable("id") Long id) {
        return broadcastAnchorServiceImpl.del(id);
    }

    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "主播状态修改")
    @PostMapping(value = "/changeStatus/{id}/{status}")
    public Boolean anchorChangeStatus(@PathVariable("id") Long id, @PathVariable("status") Integer status) {
        return broadcastAnchorServiceImpl.changeStatus(id, status);
    }
}
